// Visualization.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "World/World.h"
#include "NFData/DataMgr.h"
#include <string>
#include <sstream>
#include <iostream>
#include "Common/FileIO.h"
#include "NFData/NFAttribute.h"

using namespace std;

const float			RADIUS = 7.f;

void Save2File(int nID, NetflixDataElement element)
{
	string				filename;
	stringstream		ss;
	int					nSize = element._userComments.size();
	vector<UserComment>	list  = element._userComments;
	CFileIO				file;

	ss << nID << ".txt";
	filename = ss.str();

	file.Create(filename.c_str(), CFileIO::WRITE);

	for(int i = 0; i < nSize; i++)
	{
		stringstream str;
		str << "<review>";
		file.WriteLine(str.str().c_str());
		file.WriteLine(list[i].Comment().c_str());
		str.str("");
		str << "</review>";
		file.WriteLine(str.str().c_str());
	}

	file.Destroy();
}

int _tmain(int argc, _TCHAR* argv[])
{
	CWorld*		pWorld = CWorld::Instance();
	CDataMgr*	pDataMgr = CDataMgr::Instance();

	pWorld->Create();
	pDataMgr->Create();
	
	for(int i = 0; i < CDataMgr::NUMOFDATA; i++)
	{
		stringstream		out;
		string				str = "Movie Info";
		NetflixDataElement	data;

		out << i;
		str += out.str();

		pDataMgr->GetData(i, data);
		CATEGORY category = data.getCategory();
		pWorld->AddDynSphere(data._title, i, rVector3(rand() % 100 * (rand() % 2 == 1 ? -1 : 1), 
										  rand() % 100 * (rand() % 2 == 1 ? -1 : 1), 0),
										  RADIUS, 
										  category);
	}
	
	pWorld->AddDynSphere("Query Sphere", -1, rVector3(0, 0, 0), RADIUS, CATEGORY::QUERY);
	while(1)
	{
		pWorld->Step();
	}

	pWorld->Destroy();

	return 0;
}

